﻿#ifndef INSTRUCTIONTURNTABLEPOSITIONMODE
#define INSTRUCTIONTURNTABLEPOSITIONMODE

#include "ScriptInstruction.h"

class InstructionTurnTablePositionMode :public ScriptInstruction
{
  Q_OBJECT
private:
  ScriptRunner* scriptRunner = Q_NULLPTR;
  TurnTableCodec* turnTableCodec = Q_NULLPTR;
  float position = 0;
  float rate = 0;
  float acceleration = 0;
public:
  InstructionTurnTablePositionMode(float position, float rate, float acceleration)
  {
    scriptRunner = ScriptInstruction::getScriptRunner();
    turnTableCodec = ScriptInstruction::getTurnTableCodec();
    this->position = position;
    this->rate = rate;
    this->acceleration = acceleration;
    instructionFlag = Instruction_TurnTable_PositionMode;
  }
  ~InstructionTurnTablePositionMode()
  {}
public:
  void run()override
  {
    turnTableCodec->sendInstruction(TurnTableCodec::TurnTable_SetPositionMode,position, rate, acceleration);
    scriptRunner->scriptWaitAndRun(scriptRunner->getInterval_instruction());
  }
  QVector<float> getDataForSaving()override
  {
    QVector<float> savingData;
    savingData.append(instructionFlag);
    savingData.append(position);
    savingData.append(rate);
    savingData.append(acceleration);
    return savingData;
  }
};
#endif
